package gui.framework.intent;

import java.util.ArrayList;
import java.util.List;

public class IntentFilter {
	private List<String> actions;
	private List<String> categorys;

	public void addAction(String action) {
		if (actions == null)
			actions = new ArrayList<>();
		actions.add(action);
	}

	public void addCategory(String category) {
		if (categorys == null)
			categorys = new ArrayList<>();
		categorys.add(category);
	}

	public boolean isIntent(Intent intent) {
		if (intent == null)
			return false;
		return isIntent(intent.getAction(), intent.getCategorys());
	}

	public boolean isIntent(String action, List<String> category) {
		if (actions.contains(action)) {
			if (category != null) {
				for (String c : category) {
					if (!categorys.contains(c))
						return false;
				}
			}
			return true;
		}
		return false;
	}
}
